using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum EventType
{
    BulletKill
}
public interface EventData
{
}
public class EventDispatcher
{
    private static EventDispatcher instance = new EventDispatcher();
    public static EventDispatcher Instance
    {
        get
        {
            if (instance == null)
                instance = new EventDispatcher();
            return instance;
        }
    }
    static Dictionary<EventType, List<CallBack>> dic = new Dictionary<EventType, List<CallBack>>();
    static public void AddListener(EventType eventType, CallBack callBack)
    {
        if (!dic.ContainsKey(eventType))
        {
            dic.Add(eventType, new List<CallBack>());
            dic[eventType].Add(callBack);
        }
        else
        {

        }
    }
    static public void RemoveListener(EventType eventType, CallBack callBack)
    {
        if (!dic.ContainsKey(eventType))
        {

        }
        else
        {
            if (!dic[eventType].Contains(callBack))
            {

            }
            else
            {
                dic[eventType].Remove(callBack);
            }
        }
    }
    static public void Dispatch(EventType eventType, EventData eventData)
    {
        if (!dic.ContainsKey(eventType))
        {

        }
        else
        {
            for (int i = 0; i < dic[eventType].Count; i++)
            {
                dic[eventType][i](eventData);
            }
        }
    }
}
